﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Nest.DSL.Descriptors;

namespace XMK.Framework.ElasticSearch
{
    /// <summary>
    /// 排序
    /// 目前只支持单个字段排序
    /// </summary>
    public class ElasticSearchOrder
    {
        public ElasticSearchOrder()
        {
            SortDict = new Dictionary<string, ElasticSearchSortMode>();
        }

        public IDictionary<string, ElasticSearchSortMode> SortDict
        {
            get;
            private set;
        }

        public ElasticSearchOrder AddAscending(string fieldName)
        {
            SortDict[fieldName] = ElasticSearchSortMode.Asc;
            return this;
        }

        public ElasticSearchOrder AddDescending(string fieldName)
        {
            SortDict[fieldName] = ElasticSearchSortMode.Desc;
            return this;
        }
    }

    public enum ElasticSearchSortMode
    {
        Asc,
        Desc
    }
}
